import request from '@/utils/request'

export function listTable(data) {
  return request({
    url: '/data/market/dataTable/list',
    method: 'get',
    params: data
  })
}

export function pageTable(data) {
  return request({
    url: '/data/market/dataTable/page',
    method: 'get',
    params: data
  })
}

export function getTable(id) {
  return request({
    url: '/data/market/dataTable/' + id,
    method: 'get'
  })
}

export function delTable(id) {
  return request({
    url: '/data/market/dataTable/' + id,
    method: 'delete'
  })
}

export function delDataBatch(ids) {
  return request({
    url: '/data/market/dataTable/batch/' + ids,
    method: 'delete'
  })
}

export function addTable(data) {
  return request({
    url: '/data/market/dataTable',
    method: 'post',
    data: data
  })
}

export function updateTable(data) {
  return request({
    url: '/data/market/dataTable/' + data.id,
    method: 'put',
    data: data
  })
}

export function sqlParse(data) {
  return request({
    url: '/data/market/dataTable/sql/parse',
    method: 'post',
    data: data
  })
}

export function copyTable(id) {
  return request({
    url: '/data/market/dataTable/' + id + '/copy',
    method: 'post'
  })
}

export function releaseTable(id) {
  return request({
    url: '/data/market/dataTable/' + id + '/release',
    method: 'post'
  })
}

// 共享审批
export function releaseSubmit(id) {
  return request({
    url: '/data/market/dataTable/' + id + '/releaseSubmit',
    method: 'post'
  })
}

export function cancelTable(id) {
  return request({
    url: '/data/market/dataTable/' + id + '/cancel',
    method: 'post'
  })
}

export function word(id) {
  return request({
    url: '/data/market/dataTable/word/' + id,
    method: 'post',
    responseType: 'blob'
  })
}

export function getDataDetail(id) {
  return request({
    url: '/data/market/dataTable/detail/' + id,
    method: 'get'
  })
}
  /**
   * 资源页面的详情，参照接口文档样式做的
   * @param data
   * @returns {AxiosPromise}
   */
export function getDataTableInfoDetail(id) {
    return request({
      url: '/data/market/dataApis/tableInfoDetail/' + id,
      method: 'get'
    })
}

